package com.bw.dws;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;

public class IkUtil {
    public static Set<String> split(String s)  {
        Set<String> stringSet = new HashSet<>();
        try {
            Reader reader = new StringReader(s);
            IKSegmenter ikSegmenter = new IKSegmenter(reader,true);
            Lexeme next = ikSegmenter.next();
            while (next != null){
                String word = next.getLexemeText();
                stringSet.add(word);
                next = ikSegmenter.next();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringSet;
    }
}
